package com.heima.user;

import com.alibaba.fastjson.JSON;
import org.junit.jupiter.api.Test;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.client.RestTemplate;

import java.util.HashMap;
import java.util.Map;

public class AIYongyou {

    @Test
    public void idCardTest() {
        RestTemplate restTemplate = new RestTemplate();
        //请求头信息
        HttpHeaders httpHeaders = new HttpHeaders();
        httpHeaders.setContentType(MediaType.APPLICATION_JSON);
        httpHeaders.set("apicode", "1a354a6ee0f840af964d3dd24479c305");

        //请求参数
        Map<String, String> paramMap = new HashMap<>();
        paramMap.put("idNumber", "430426200101209631");
        paramMap.put("userName", "龙涛");

        HttpEntity<String> httpEntity = new HttpEntity<>(JSON.toJSONString(paramMap), httpHeaders);

        ResponseEntity<String> responseEntity = restTemplate.postForEntity("https://api.yonyoucloud.com/apis/dst/matchIdentity/matchIdentity", httpEntity, String.class);
        System.out.println(responseEntity.getBody());
    }
}
